﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class admin_cms_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {

        }
    }
    protected void bt_click_login(object sender, EventArgs e)
    {

        //string name =  DataAccess.GetMD5(txttendn.Text.ToString());
        //string pass = DataAccess.GetMD5(txtmatkhau.Text.ToString());
        string name = txttendn.Text.ToString();
        string pass = txtmatkhau.Text.ToString();
        DataTable dt_login = new DataTable();
        dt_login = DataAccess.ExeStoredToDataTable("admin_alluser_select", "@user", name, "@pass", pass);
        if (dt_login.Rows.Count > 0)
        {
            Session.Add("timeout", name);
            Session.Add("Name", dt_login.Rows[0][3].ToString());
            //lấy id group ở bảng user, rồi lấy ra tên group ở bảng groupuser
            int idgroup = Convert.ToInt32(dt_login.Rows[0][9].ToString());
            DataTable dtgroupuser = new DataTable();
            dtgroupuser = DataAccess.ExeSQLToDataTable("select * from admin_groupuser where idgroup='" + idgroup + "'");
            if (dtgroupuser.Rows.Count>0)
            {
                //lưu tên nhóm vào sesison để kiểm tra
                Session.Add("NameGroup",dtgroupuser.Rows[0][1].ToString());
                Response.Redirect("admin_add_menu.aspx");
            }
           

        }
        else
        {

        }

    }
}
